using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
using System.Windows.Forms;
using System.Xml.Serialization;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;

namespace ReportMaintenanceUtility
{
	/// <summary>
	/// Defines a SQL Parameter used by a DataSet
	/// </summary>
	public class QueryParameter : GenericBase
	{
		#region PRIVATE MEMBERS
		private string _name = string.Empty;
		private string _value = string.Empty;
		private QueryParameterType _origObj = null;
		#endregion

		#region PUBLIC PROPERTIES
		/// <summary>
		/// Name of a SQL Parameter used in the query or stored procedure of the parent DataSet object
		/// </summary>
		public string Name
		{
			get { return this._name; }
			set
			{
				this.PrepStateChange();
				this._name = value;
				this._isDirty = true;
				this.NotifyPropertyChanged("Name");
			}
		}
		/// <summary>
		/// A literal value or expression (ex: "=Parameters!AsOfDate.Value") passed as the input value to the associated query or stored procedure
		/// </summary>
		public string Value
		{
			get { return this._value; }
			set
			{
				this.PrepStateChange();
				this._value = value;
				this._isDirty = true;
				this.NotifyPropertyChanged("Value");
			}
		}
		#endregion

		#region CONSTRUCTOR(S)
		private QueryParameter(QueryParameter qp)
		{
			this._name = qp.Name;
			this._value = qp.Value;
		}
		public QueryParameter(QueryParameterType qpt)
		{
			this._name = qpt.Name;
			this._origObj = qpt;
			if (qpt.Items.Length > 0 && qpt.Items[0] != null)
			{
				this._value = qpt.Items[0].ToString();
			}
		}
		#endregion

		#region INTERFACE IMPLEMENTATION(S)
		public override bool Equals(GenericBase other)
		{
			if (other != null && other is QueryParameter)
			{
				return this.Equals((QueryParameter)other);
			}
			else
			{
				return false;
			}
		}
		public bool Equals(QueryParameter other)
		{
			if (other == null)
			{
				return false;
			}
			return (this.Value.Equals(other.Value, StringComparison.CurrentCultureIgnoreCase) &&
				this.Name.Equals(other.Name, StringComparison.CurrentCultureIgnoreCase));
		}
		public override List<ChangeLog> SaveState()
		{
			throw new Exception("The method or operation is not implemented.");
		}
		public override void RestoreState()
		{
			if (this._copy != null)
			{
				this._name = this._copy.Name;
				this._value = this._copy.Value;
				this._copy = null;
			}
			this._isDirty = false;
		}
		public override QueryParameter CreateDeepCopy()
		{
			return new QueryParameter(this);
		}
		public QueryParameterType GetSeedObject()
		{
			return this._origObj;
		}
		#endregion
	}
}